//
//  FormControl.h
//  iCodeMac
//
//  Created by Andrew Barry on 21/10/09.
//  Copyright 2009 Barry Computer Services. All rights reserved.
//

#import <Cocoa/Cocoa.h>

@class JavascriptForm;
@class FormEditor;
@class FormView;
@class FormEditorOverlay;

@interface FormControl : NSObject {
	NSString *controlName;
	FormControl *parent;
	NSView *view;
	NSString *controlType;
	JavascriptForm *formDocument;
	FormEditorOverlay *formOverlay;
	NSRect savePos;
	//	id info;
	bool lockLeft, lockTop, lockRight, lockBottom;
	bool visible, enabled;
	NSMutableDictionary *events;
}

-(id)init;
-(void)loadEvent: (NSString *) name fromSave: (NSDictionary *) defn;
-(void) saveEvents: (NSMutableDictionary *) content;
-(void) saveField: (NSMutableDictionary *) content forKey:(NSString *) name;
-(NSView *) view;

-(void) setView: (NSView *) v;
-(void) setDocument: (JavascriptForm *) doc;
-(void) setOverlay: (FormEditorOverlay *) overlay;
-(void) setControlType: (NSString *) controlType;
-(void) moveControl: (NSValue *) newPos;
-(void) setSavePos: (NSRect) pos;
-(NSRect) savePos;
-(bool) wasMoved;
-(void) setControlName: (NSString *) v;
-(NSString *) controlName;
-(NSString*) typeName;
-(void) updateSizing;
-(void)broadcastPosition;
-(NSArray *) autocompletes;

//-(id) info;
//-(void) setInfo: (id) info;
-(id) valueForProperty: (NSString *) name;
-(void) setValue: (id) val forProperty:(NSString*) name;
-(NSDictionary *) save;
-(void) saveFields: (NSMutableDictionary *) content;
+(FormControl *) loadFromSave: (NSDictionary *) defn forEditor: (FormEditor *) editor;
-(NSArray *) getEvents;
-(NSString *) sourceForEvent: (NSString *) eventName;
-(void) commitSource: (NSString *) source forEvent: (NSString *) eventName;
-(NSString *) propsNibName;
-(FormControl *)parent;
-(void)setParent: (FormControl *) newParent;
-(void) postLoad;

@end
